var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');


var app = getApp();

Page({
  data: {
    footprintList: null,
  },

  onLoad: function (options) {
    this.getFootprintList();
  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  },
  getFootprintList() {
    let that = this;
    util.request(api.FootPrintList).then(function (res) {
      console.log(res);
      if (res.code == 200) {
        that.setData({
          footprintList: res.responseBody.campaignList
        });
      }
    });
  },
  touchItem: function(e){
    console.log(e)
    var campaign_id = e.currentTarget.dataset.cid;
    wx.navigateTo({
      url: '/pages/goods/goods?id='+campaign_id,
    })
  },
  deleteItem(e) {
    console.log(e)
    let that = this;

    var orderid = e.currentTarget.dataset.orderid;
 
      wx.showModal({
        title: '',
        content: '要删除所选足迹？',
        success: function (res) {
          if (res.confirm) {
            util.request(api.DeleteFootPrint + orderid, {},'POST')
            .then(function (res){
              console.log(res)
              if (res.code === 200) {
                wx.showToast({
                  title: '删除成功',
                  icon: 'success',
                  duration: 2000
                });
                that.getFootprintList();
              }
            });
            console.log('用户点击确定')
          }
        }
      });
 

  }
})